# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-filemagic
pkgname=('python2-filemagic' 'python-filemagic')
_pkgname=filemagic
pkgver=1.6
_pyver=3.13
pkgrel=13
pkgdesc='A Python API for libmagic, the library behind the Unix file command.'
url='https://pypi.org/project/filemagic/#files'
arch=('any')
license=('Apache')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('2b33b55467d14697ddcee2b1cb69eb41dd51474d2d8d095873f6f6609d77efa295a91bc9b976c9af22983a7cc801e1ea1e55163c18c5b6a41c4e1ff9cf73bb47')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-filemagic() {
  depends=('python2')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  mv "$pkgdir/usr/lib/python2.7/site-packages/magic" \
    "$pkgdir/usr/lib/python2.7/site-packages/filemagic"
}

package_python-filemagic() {
  depends=('python')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  mv "$pkgdir/usr/lib/python$_pyver/site-packages/magic" \
    "$pkgdir/usr/lib/python$_pyver/site-packages/filemagic"
}

